import React, { useEffect, useState } from 'react';
import axios from 'axios'
const List = (props) => {
    const [shopList, setShopList] = useState([])
    console.log(props.match.params.type)
    useEffect(() => {
        axios.get('/shop').then(res => {
            setShopList(res.data.filter(item => item.type == props.match.params.type))
        })
    }, [])
    return (
        <div>
            {shopList.map((item, index) => {
                return <div key={index} onClick={() => {
                    props.history.push('/detail/' + item.id)
                }}>
                    <img src={item.image} alt="" />
                    {item.title}
                </div>
            })}
        </div>
    );
}

export default List;
